package com.itkm.eurekaconsumer.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class RibbonConsumerController {
    private static final String REST_URL_PREFIX = "http://eureka-provider/";
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/ribbon_consumer/{path}")
    public Object discovery(@PathVariable("path") String path) {
        return restTemplate.getForObject(REST_URL_PREFIX + path, Object.class);
    }
}
